﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PTCTTCNBK.Models;

namespace PTCTTCNBK.Controllers
{
    public class AuthorityController : Controller
    {
        //
        // GET: /Authority/

        public ActionResult ManageUsers()
        {
            /*var dataContext = new DatabaseDataContext();

            var userList = (from u in dataContext.PtcTbl_Users
                            join g in dataContext.PtcTbl_Groups on u.GroupID equals g.ID
                            select new UserAndGroupModel { user = u, gr = g }).ToList();
             return View(userList);*/

            var dataContext = new PetroDataContext();
            //var or = (from x in dataContext.PtcTbl_Bills
            //          where x.Type == false
            //          select new ).ToList();

            UserAndGroup itemResult = new UserAndGroup();
            itemResult.Users = dataContext.PtcTbl_Users.ToList();
            itemResult.Groups = dataContext.PtcTbl_Groups.ToList();

            //var res = (from x in dataContext.PtcTbl_Bills
            //           join y in dataContext.PtcTbl_Products
            //           on x.ProductID equals y.ID
            //           orderby x.ID descending
            //           where x.Type == false      
            //           select new BillAndProduct { Bill = x}).ToList();

            //res.FirstOrDefault().Product= 
            return View(itemResult);



        }

        public ActionResult ManageGroups()
        {
            return View();
        }

        public ActionResult ManageAuthorities()
        {
            return View();
        }

        public class UserAndGroup
        {
            public List<PTCTTCNBK.Models.PtcTbl_User> Users { get; set; }
            public List<PTCTTCNBK.Models.PtcTbl_Group> Groups { get; set; }
        }
    }
}
